package com.airikeji.hr.controller;

//import com.airikeji.hr.rabbitmq.RabbitMQSendUtil;
import com.airikeji.hr.rabbitmq.RabbitMQSendUtil;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author huangrui
 * @Date 2021/7/9 14:34
 * @Version 1.0
 */
@RestController
@RequestMapping("/rabbitmq")
public class MessageController {

    @Autowired
    private RabbitMQSendUtil rabbitMQSendUtil;

    @PostMapping("/send")
    public void sendMessaage(@RequestParam("message") String message, @RequestParam("exchange")String exchange, @RequestParam(value = "routeKey", required = false)String routeKey){

        if (routeKey != null){
            rabbitMQSendUtil.send(exchange, message, routeKey);
        }else {
            rabbitMQSendUtil.send(exchange, message);
        }
    }


}
